cmake_minimum_required(VERSION 3.5)
project(collectc_test)

find_package(PkgConfig)
pkg_check_modules(CPPUTEST REQUIRED cpputest>=3.8)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPPUTEST_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CPPUTEST_C_FLAGS}")

set(array_test_sources array_test.c arrayTest.cpp)
set(deque_test_sources deque_test.c dequeTest.cpp)
set(list_test_sources list_test.c listTest.cpp)
set(hashset_test_sources hashset_test.c hashsetTest.cpp)
set(hashtable_test_sources hashtable_test.c hashtableTest.cpp)
set(pqueue_test_sources pqueue_test.c pqueueTest.cpp)
set(queue_test_sources queue_test.c queueTest.cpp)
set(slist_test_sources slist_test.c slistTest.cpp)
set(stack_test_sources stack_test.c stackTest.cpp)
set(treeset_test_sources treeset_test.c treesetTest.cpp)
set(treetable_test_sources treetable_test.c treetableTest.cpp)
set(rbuf_test_sources rbuf_test.c rbufTest.cpp)

include_directories(${PROJECT_SOURCE_DIR}/include ${collectc_INCLUDE_DIRS} ${CPPUTEST_INCLUDE_DIRS})

add_executable(array_test ${array_test_sources})
add_executable(deque_test ${deque_test_sources})
add_executable(hashset_test ${hashset_test_sources})
add_executable(hashtable_test ${hashtable_test_sources})
add_executable(list_test ${list_test_sources})
add_executable(pqueue_test ${pqueue_test_sources})
add_executable(queue_test ${queue_test_sources})
add_executable(slist_test ${slist_test_sources})
add_executable(stack_test ${stack_test_sources})
add_executable(treeset_test ${treeset_test_sources})
add_executable(treetable_test ${treetable_test_sources})
add_executable(rbuf_test ${rbuf_test_sources})

target_link_libraries(array_test collectc ${CPPUTEST_LDFLAGS})
target_link_libraries(deque_test collectc ${CPPUTEST_LDFLAGS})
target_link_libraries(list_test collectc ${CPPUTEST_LDFLAGS})
target_link_libraries(hashset_test collectc ${CPPUTEST_LDFLAGS})
target_link_libraries(hashtable_test collectc ${CPPUTEST_LDFLAGS})
target_link_libraries(pqueue_test collectc ${CPPUTEST_LDFLAGS})
target_link_libraries(queue_test collectc ${CPPUTEST_LDFLAGS})
target_link_libraries(slist_test collectc ${CPPUTEST_LDFLAGS})
target_link_libraries(stack_test collectc ${CPPUTEST_LDFLAGS})
target_link_libraries(treeset_test collectc ${CPPUTEST_LDFLAGS})
target_link_libraries(treetable_test collectc ${CPPUTEST_LDFLAGS})
target_link_libraries(rbuf_test collectc ${CPPUTEST_LDFLAGS})

add_test(ArrayTest array_test -c -v)
add_test(DequeTest deque_test -c -v)
add_test(ListTest list_test -c -v)
add_test(HashSetTest hashset_test -c -v)
add_test(HashTableTest hashtable_test -c -v)
add_test(PQueueTest pqueue_test -c -v)
add_test(QueueTest queue_test -c -v)
add_test(SlistTest slist_test -c -v)
add_test(StackTest stack_test -c -v)
add_test(TreeSetTest treeset_test -c -v)
add_test(TreeTableTest treetable_test -c -v)
add_test(RbufTest rbuf_test -c -v)
